module.exports = {

    async curl(url, config) {
        let now = Date.now();

        let result;
        result = await this.ctx.curl(url, config);

        var data = result.data;

        var transformationResult = {
            Original: result,
            status: result.status,
            headers: result.headers,
            data: {
                meta: {
                    success: data.code == 0,
                    message: data.message
                },
                data: data.data
            }
        }
        if (data.code == 999) {
            transformationResult.status = 401;
        }

        if (result.status == 500) {
            //transformationResult.status = 500;
            this.ctx.message = '服务器接口调用异常'
            transformationResult.data = '服务器接口调用异常'
        }


        return transformationResult;
    },


    isMobile() {
        let ua = this.ctx.get('user-agent');
      
        let isMobile = !!ua.match(/AppleWebKit.*Mobile.*/) 


       

        return isMobile;
    }
}